#!/usr/bin/env bash

set -ex

mkdir -p build && cd build

git clone --depth=1 https://github.com/raspberrypi/userland

rm -rf ./userland/build && mkdir -p ./userland/build

cd ./userland/build

cmake -DCMAKE_SYSTEM_NAME=Linux -DCMAKE_BUILD_TYPE=release -DARM64=ON -DCMAKE_C_COMPILER=aarch64-linux-gnu-gcc -DCMAKE_CXX_COMPILER=aarch64-linux-gnu-g++ -DCMAKE_ASM_COMPILER=aarch64-linux-gnu-gcc -DVIDEOCORE_BUILD_DIR=/opt/vc ../

make -j $(nproc)
